package com.smartwebx.ha.web.util.valve;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.service.pipeline.PipelineContext;
import com.alibaba.citrus.turbine.pipeline.valve.AbstractInputOutputValve;

public class ResultJsonValve extends AbstractInputOutputValve {
	@Autowired
	private HttpServletResponse response;
	
	@Override
	public void invoke(PipelineContext pipelineContext) throws Exception {
		response.setContentType("application/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		Object resultObject = consumeInputValue(pipelineContext);
		out.print(resultObject);
		pipelineContext.invokeNext();
	}
}